package com.rede.didiok.user.modulelist.rank.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.rede.didiok.common.utils.PageUtils;
import com.rede.didiok.common.utils.R;
import com.rede.didiok.user.modulelist.rank.entity.MilestoneEntity;
import com.rede.didiok.user.modulelist.rank.service.MilestoneService;


/**
 * 里程碑事件、战绩、闪光点
 *
 * @author Rede
 * @email didiok@foxmail.com
 * @date 2023-07-20 22:09:24
 */
@RestController
@RequestMapping("rank/milestone")
public class MilestoneController {
    @Autowired
    private MilestoneService milestoneService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    // @RequiresPermissions("rank:milestone:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = milestoneService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{milestoneId}")
    // @RequiresPermissions("rank:milestone:info")
    public R info(@PathVariable("milestoneId") Long milestoneId){
		MilestoneEntity milestone = milestoneService.getById(milestoneId);

        return R.ok().put("milestone", milestone);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    // @RequiresPermissions("rank:milestone:save")
    public R save(@RequestBody MilestoneEntity milestone){
		milestoneService.save(milestone);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    // @RequiresPermissions("rank:milestone:update")
    public R update(@RequestBody MilestoneEntity milestone){
		milestoneService.updateById(milestone);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    // @RequiresPermissions("rank:milestone:delete")
    public R delete(@RequestBody Long[] milestoneIds){
		milestoneService.removeByIds(Arrays.asList(milestoneIds));

        return R.ok();
    }

}
